package com.sun.stringescapeutils;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@Slf4j
@RestController
@RequestMapping("/mail")
public class MailTemp {

    @Autowired
    private JavaMailSender mailSender;
    @RequestMapping("/sendTemp")
    public void sendMail(){
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom("thesunxueteng@163.com");
        simpleMailMessage.setTo("1791540641@qq.com");
        simpleMailMessage.setSubject("it is a test for spring boot");
        simpleMailMessage.setText("您好，我是小黄，我正在测试发送邮件");
        try{
            mailSender.send(simpleMailMessage);
            log.info("小黄的测试短信发送成功！");
        }catch (Exception e){
            log.error("小黄的测试短信发送失败："+e);
        }
    }
}
